//
//  HuiFoodCell.m
//  DongChiDaChiProject1
//
//  Created by lanou3g on 15/10/28.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "HuiFoodCell.h"

@implementation HuiFoodCell

- (void)awakeFromNib {

}
// 重写方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [[UIColor orangeColor]colorWithAlphaComponent:0.2];
        // 调用方法
        [self addSubViews];
    }
    return self;
}

//在这里布局子视图
- (void)addSubViews
{
    
    // 设置大背景
    UIView *backGroundView = [[UIView alloc] initWithFrame:CGRectMake(5 * kWidthFitParameter, 5 * kWidthFitParameter, kScreenWidth - 10 * kWidthFitParameter, 160 * kWidthFitParameter)];
    backGroundView.layer.cornerRadius = 5 * kWidthFitParameter;
    backGroundView.layer.masksToBounds = YES;
    backGroundView.backgroundColor = [UIColor whiteColor];
    [self addSubview:backGroundView];
    // 设置图片
    self.imageBackPicture = [[UIImageView alloc] initWithFrame:CGRectMake(20 * kWidthFitParameter, 20 * kWidthFitParameter, 140 * kWidthFitParameter, 120 * kWidthFitParameter)];
    self.imageBackPicture.layer.cornerRadius = 10 * kWidthFitParameter;
    self.imageBackPicture.layer.masksToBounds = YES;
    self.imageBackPicture.backgroundColor = [UIColor yellowColor];
    [ backGroundView addSubview:self.imageBackPicture];
    
    // 设置标题
    self.titleLable = [[UILabel alloc] initWithFrame:CGRectMake(self.imageBackPicture.right + 10 * kWidthFitParameter, self.imageBackPicture.top + 10 * kWidthFitParameter, 150 * kWidthFitParameter, 30 * kWidthFitParameter)];
    self.titleLable.font = [UIFont systemFontOfSize:18 * kWidthFitParameter];
    self.titleLable.textAlignment = NSTextAlignmentLeft;
    //self.titleLable.backgroundColor = [UIColor greenColor];
    [backGroundView addSubview:self.titleLable];
    // 设置类目
    self.categoryLable = [[UILabel alloc] initWithFrame:CGRectMake(self.imageBackPicture.right + 10 * kWidthFitParameter, self.titleLable.bottom, 170 * kWidthFitParameter, 45 * kWidthFitParameter)];
    self.categoryLable.font = [UIFont systemFontOfSize:15 * kWidthFitParameter];
    self.categoryLable.numberOfLines = 0;
    //self.categoryLable.backgroundColor = [UIColor whiteColor];
    [backGroundView addSubview:self.categoryLable];
    
    // 设置 view
    self.viewsLable = [[UILabel alloc] initWithFrame:CGRectMake(self.imageBackPicture.right + 100 * kWidthFitParameter, self.categoryLable.bottom, 100 * kWidthFitParameter, 20 * kWidthFitParameter)];
    self.viewsLable.font = [UIFont systemFontOfSize:13 * kWidthFitParameter];
    //self.viewsLable.backgroundColor = [UIColor redColor];
    self.viewsLable.textAlignment = NSTextAlignmentRight;
    [backGroundView addSubview:self.viewsLable];
    
    // 设置菜系
    self.caixiLable = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 60 * kWidthFitParameter, 10 * kWidthFitParameter, 40 * kWidthFitParameter, 30 * kWidthFitParameter)];
    self.caixiLable.layer.cornerRadius = 10 * kWidthFitParameter;
    self.caixiLable.layer.masksToBounds = YES;
    self.caixiLable.textColor = [UIColor whiteColor];
    self.caixiLable.font = [UIFont systemFontOfSize:15 * kWidthFitParameter];
    self.caixiLable.textAlignment = NSTextAlignmentCenter;
    self.caixiLable.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.caixiLable];
}
// 赋值
- (void)setModel:(EightFoodModel *)model
{
    // 大背景片赋值
    [self.imageBackPicture sd_setImageWithURL:[NSURL URLWithString:model.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    // 目录赋值
    self.categoryLable.text = [NSString stringWithFormat:@"%@", model.category];
    // 标题赋值
    self.titleLable.text = [NSString stringWithFormat:@" %@", model.title];
    self.viewsLable.text = [NSString stringWithFormat:@"%@人看过", model.views];
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
